package com.learn.mapstruct.condition;

import com.learn.mapstruct.condition.kit.ConditionKit;
import com.learn.mapstruct.condition.model.ConditionEntity;
import com.learn.mapstruct.condition.model.ConditionEntity2;
import org.mapstruct.Context;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(imports = ConditionKit.class)
public interface ConditionMapper {

    @Mapping(target = "id", source = "id", conditionQualifiedByName = "condition2")
    @Mapping(target = "name", source = "name", conditionQualifiedByName = "condition1")
    @Mapping(target = "name2", source = "name2", conditionQualifiedByName = "condition3")
    @Mapping(target = "name3", source = "name3", conditionQualifiedByName = "condition4")
    @Mapping(target = "name4", source = "name4", conditionExpression = "java(entity.getId() != null && cn.hutool.core.util.StrUtil.isNotBlank(entity.getName4()))")
    @Mapping(target = "name5", source = "name5", conditionQualifiedByName = "condition5")
    ConditionEntity2 to(ConditionEntity entity, @Context String data);
}
